preservefa5d603525016f21
preservea93b8c039114fcf9
preserved11f17e1bfb0f149
---
title: "Dashboard"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
source: embed
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(p8105.datasets)
library(plotly)
```
```{r}
data("instacart")
instacart1 =
instacart %>%
select(order_id, product_id, user_id, order_dow, order_hour_of_day, days_since_prior_order, product_name, aisle_id, aisle, department_id, department) %>%
sample_n(5000)
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
instacart1 %>%
count(aisle) %>%
mutate(aisle = factor(aisle),
aisle = fct_reorder(aisle, n)) %>%
plot_ly(
x = ~aisle, y = ~n, color = ~aisle, type = "bar",
colors = "viridis"
)
```
Column {data-width=350}
-----------------------------------------------------------------------
### Chart B
```{r}
instacart1 %>%
mutate(department = factor(department),
department = fct_reorder(department, days_since_prior_order)) %>%
plot_ly(
x = ~department, y = ~days_since_prior_order, color = ~department, type = "box",
colors = "viridis"
)
```
### Chart C
```{r}
instacart1 %>%
group_by(department) %>%
count(order_hour_of_day) %>%
plot_ly(
x = ~order_hour_of_day, y = ~n, color = ~department, type = "scatter",
mode = "lines", colors = "viridis"
)
```